package com.atom.module.mvvm.base.viewmodel

import androidx.fragment.app.Fragment
import com.atom.module.mvvm.base.ApiModel
import com.atom.module.mvvm.livedata.SingleLiveData
import java.util.HashMap


abstract class AbstractBaseContainerViewModel<M : ApiModel> : AbstractBaseViewModel<M> {

    constructor(model: M) : super(model)

    internal val startFragmentAction = SingleLiveData<Map<String, Any>>()

    internal val startFragmentForResultAction = SingleLiveData<Map<String, Any>>()

    fun startFragment(fragment: Fragment, addToBackStack: Boolean = true) {
        val params: MutableMap<String, Any> = HashMap()
        params[ParameterField.fragment] = fragment
        params[ParameterField.addToBackStack] = addToBackStack
        startActivityAction.postValue(params)
    }

    object ParameterField {
        val EXTRA_FRAGMENT_CLASS_NAME = "activity.fragment.classname"
        val fragment = "fragment"
        val addToBackStack = "addToBackStack"
    }
}
